@isTest
private class EquipmentCountTest{
  static testMethod void testMethod1(){
           
        EquipmentCountSchedule sc = new EquipmentCountSchedule();
        String fmt = '0 10 0 1-31 1-12 ? 2017-2098';//每天执行一次
        System.schedule('每天刷新'+Datetime.now().format('yyyyMMddHHmmss'), fmt, sc);
    }
    
   static testMethod void testMethod2(){
         Product__c p1=TestUtils.createProduct();
        p1.Name='仪器';
        p1.Category0__c = '仪器';
        p1.Model__c='Model1228';
       // p1.ProductStructure__c=ps1.Id;
       // p1.CRMBrand__c = brand.Id;
        p1.RecordTypeId =  Utils.getRecordTypeIdByDevNameAndObjName('NCProduct','Product__c');
        insert p1;

         Account acc=new Account();
        acc.Name='Test1229J';
        acc.Level__c = '一级医院';
        insert acc;
        Dealer__c d = new Dealer__c(
            Only__c='Dealer__c'
        );
        insert d;



        Case cas=new Case();
        cas.AccountId=acc.Id;
        cas.Servicetype__c = '应用';
        insert cas;

        Equipment__c e1 = new Equipment__c();
        e1.Account__c = acc.Id;
        e1.IMEINumber__c = '11';
        e1.EndDate__c = System.today();
        e1.Product__c = p1.Id;
        insert e1;

        WorkOrder__c wo=new WorkOrder__c();
        wo.Case__c=cas.Id;
        wo.Account__c=acc.Id;
        wo.Status__c='完成';
        wo.ManufactureInfo__c=p1.Id;
        wo.ServiceManufacture__c = e1.Id;
        wo.IMEINumber__c = '1245';
        wo.recordTypeId = Utils.getRecordTypeIdByDevNameAndObjName('InstallationOrder','WorkOrder__c');
        wo.WhetherToMakeASingle__c = '否';
        insert wo;


         Case cas1=new Case();
        cas1.AccountId=acc.Id;
        insert cas1;

        WorkOrder__c wo1=new WorkOrder__c();
        wo1.Case__c=cas1.Id;
        wo1.Account__c=acc.Id;
        wo1.Status__c='完成';
        wo1.ManufactureInfo__c=p1.Id;
        wo1.ServiceManufacture__c = e1.Id;
        wo1.Install_End_Datetime__c = System.now();
        wo1.IMEINumber__c = '1245';
        wo1.recordTypeId = Utils.getRecordTypeIdByDevNameAndObjName('MaintenanceOrder','WorkOrder__c');
        wo1.WhetherToMakeASingle__c = '否';
        insert wo1;




         EquipmentCountBatch batch = new EquipmentCountBatch();
         batch.execute(null , new List<Equipment__c>{e1});

          database.executeBatch(batch,1);
        
         Test.startTest();
         String fmt = '0 10 0 1-31 1-12 ? 2017-2098';//每天执行一次
         String jobId = System.schedule('testBasicScheduledApex',fmt,
                new EquipmentCountSchedule());
         CronTrigger ct = [SELECT Id, CronExpression, TimesTriggered,NextFireTime
                            FROM CronTrigger WHERE id = :jobId];
            
         System.assertEquals(fmt,ct.CronExpression);
         Test.stopTest();
    }
}